package controller

import (
	"github.com/gin-gonic/gin"
	ws_print "print-link/down/ws"
	"print-link/fw_log"
	"print-link/fw_utils"
)

type wmsController struct {
}

func (controller *wmsController) Print(c *gin.Context) {
	printJson := c.Query("content")
	fw_log.Slogger.Infoln("打印模板数据--->", printJson)
	fw_log.Slogger.Infoln("模板数据大小--->", len(printJson))
	err := ws_print.WsClient.SendTextMessage(printJson)
	if err != nil {
		fw_log.Slogger.Infoln("ws方式发送数据到tool错误--->", err.Error())
		fw_utils.Error(c, -1, err, "ok")
	}
	fw_utils.OK(c, "", "ok")
}

func WmsRoute(r *gin.Engine) {
	controller := wmsController{}
	v1 := r.Group("/wms")
	{
		v1.GET("/v1/print", controller.Print)
	}
}
